package com.kuang.api.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kuang.api.entity.User;
import com.kuang.api.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 狂神说
 * @since 2021-06-03
 */
@RestController
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping("/test")
    public List<User> userList(){
        return userService.list();
    }

    @RequestMapping("/test2")
    public void userList2(){
        userService.test();
    }

    @RequestMapping("/fenye")
    public PageInfo<User> userList3(){
        int pageNo=1;
        int pageSize=10;
        PageHelper.startPage(pageNo,pageSize);
        List<User> list = userService.list();
        PageInfo<User> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}

